package work.mediway.mdm.core.enums;

import cn.hutool.core.util.StrUtil;
import cn.hutool.http.Method;

/**
 * @author zhongyj <1126834403@qq.com><br/>
 * @date 2022/3/24
 */
public enum MethodEnum {
    /**
     * 请求方式
     */
    GET, POST, HEAD, OPTIONS, PUT, DELETE, TRACE, CONNECT, PATCH;

    MethodEnum() {
    }

    public static MethodEnum get(String method) {
        MethodEnum[] values = MethodEnum.values();
        for (MethodEnum methodEnum : values) {
            if (StrUtil.equalsIgnoreCase(methodEnum.name(), method)) {
                return methodEnum;
            }
        }
        return null;
    }

    public static Method convert(MethodEnum methodEnum) {
        for (Method method : Method.values()) {
            if (StrUtil.equalsIgnoreCase(method.name(), methodEnum.name())) {
                return method;
            }
        }
        return null;
    }
}
